﻿using Dapper;
using System;
using System.Collections.Generic;
using System.Data;

namespace hCommand
{
    /**
   *┌────────────────────────────────────────────────┐
   *│　描    述：LocSelect                                                    
   *│　作    者：sgj                                              
   *│　版    本：1.0                                              
   *│　创建时间：2021/9/8 16:59:49                        
   *└────────────────────────────────────────────────┘
   **/
    public abstract class LocSelect
    {
        public virtual bool canWork(long meId, long beforeId, List<long> relyTask)
        {
            return true;
        }
        public abstract CoreWhLoc select<CS>(List<CoreWhLoc> locList, long goodDiff, CS cs) where CS : AbsCoreStock;
       


        public virtual bool isLoc(long loc)
        {
            return loc > 10000;
        }

        public virtual bool isAreaGroup(int id)
        {
            return id % 10000 >= 9000;
        }
        public virtual int getId(IDbConnection conn, IDbTransaction tran, int moveGroup)
        {
            int id = moveGroup * 10000 + 9000;
            while (id / 10000 == moveGroup)
            {
                CoreWhGroup group = conn.GetById<CoreWhGroup>(id, tran);
                if (group == null)
                {
                    return id;
                }
                id++;
                if (id >= (moveGroup + 1) * 10000)
                {
                    break;
                }
            }
            throw new Exception(moveGroup + "库区太多");
        }

    }
}
